package fr.unice.polytech.plim.podometre;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;



class Bdd extends SQLiteOpenHelper {

	public static final String KEY_ID= "_id";
	
	public static final String KEY_DATE ="DATE";
	public static final String KEY_POSITION_LAT = "POSITION_LAT";
	public static final String KEY_POSITION_LONG = "POSITION_LONG";
	public static final String KEY_POSITION_ALT= "POSITION_ALT";
	public static final String KEY_VITESSE = "VITESSE";
	
	public static final String DATABASE_NAME ="myDatabase.db";
	public static final String DATABASE_TABLE = "PODOMETRE";
	public static final int DATABASE_VERSION = 1;
	
	
	private static final String DATABASE_CREATE = "create table " + DATABASE_TABLE + " ("+ KEY_ID+ " integer primary key autoincrement, "+
	KEY_DATE+" long, "+
			KEY_POSITION_LAT + " float, "+
			KEY_POSITION_LONG + " float, "+
			KEY_POSITION_ALT + " float,"+
			KEY_VITESSE + " float );";
	
	public Bdd(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		//db.execSQL("DROP TABLE IF EXISTS" + DATABASE_TABLE);
		db.execSQL(DATABASE_CREATE);
	}
	
		


	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w("TaskDBAdapter", "Mise a jour de la version" + oldVersion + " vers la version "+
				newVersion + ", ce qui detruira toutes les anciennes donnees");
		
		db.execSQL("DROP TABLE IF EXISTS" + DATABASE_TABLE);
		onCreate(db);
	}
	@Override
	public synchronized void close() {
		// TODO Auto-generated method stub
		super.close();
	}
	
	
	
}